package main

import (
	"fmt"
	"math"
)
//变量参数
func sum(args ...int) int {
	s := 0
	for _, number := range args {
		s += number
	}
	return s
}
func main() {
	hypot := func(x, y float64) float64 {
		return math.Sqrt(x * x + y * y)
	}

	fmt.Println(hypot(3, 4))

	total := sum(1, 2, 3, 5)
	fmt.Println(total)

	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	//将切片传sum时，要用...展开否则将作为一个参数处理等价于sum(1, 2, 3, 4, 5, 6, 7, 8, 9)
	total = sum(slice...)
	fmt.Println(total)

}
